From: Florian Müllner Date: Tue, 9 Jun 2020 23:45:08 +0000 (+0200) Subject: swipeTracker: Reject touchpad swipes in the wrong directions X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~616^2^2~313 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=e135f077fb3b716ef34e219b388d0911b0a7e5f3;p=gnome-shell.git swipeTracker: Reject touchpad swipes in the wrong directions We now have multiple touch swipe gestures with matching fingers and different directions set on the overview hierarchy. Accepting all touchpad swipes without checking the direction makes one of these gestures take control of input, without other gestures having a say on this. So, look for the direction of the swipe events and look if it matches the expected orientation. Part-of: --- diff --git a/js/ui/swipeTracker.js b/js/ui/swipeTracker.js index 7bd4a96bd..5bc2c49e4 100644 --- a/js/ui/swipeTracker.js +++ b/js/ui/swipeTracker.js @@ -124,6 +124,17 @@ const TouchpadSwipeGesture = GObject.registerClass({ let [x, y] = event.get_coords(); let [dx, dy] = event.get_gesture_motion_delta(); + let gestureOrientation = -1; + if (dx !== dy) { + gestureOrientation = Math.abs(dx) > Math.abs(dy) + ? Clutter.Orientation.HORIZONTAL + : Clutter.Orientation.VERTICAL; + } + + if (gestureOrientation >= 0 && + gestureOrientation !== this.orientation) + return Clutter.EVENT_PROPAGATE; + const vertical = this.orientation === Clutter.Orientation.VERTICAL; let delta = (vertical ? dy : dx) * SWIPE_MULTIPLIER; const distance = vertical ? TOUCHPAD_BASE_HEIGHT : TOUCHPAD_BASE_WIDTH; @@ -146,7 +157,9 @@ const TouchpadSwipeGesture = GObject.registerClass({ break; } - return Clutter.EVENT_STOP; + return gestureOrientation === this.orientation + ? Clutter.EVENT_STOP + : Clutter.EVENT_PROPAGATE; } destroy() {